package com.wyg.iterator;

import java.util.Arrays;

/**
 * @description:
 * @author: WYG
 * @time: 2021/4/6 9:10
 */

public class DinerMenu {
    private static final int MAX_ITEMS = 6;
    private int numberOfItems = 0;
    private MenuItem[] menuItems;

    public DinerMenu() {
        menuItems = new MenuItem[MAX_ITEMS];
        addItem("BLT", "tomato", true, 3.29);
    }

    public void addItem(String name, String description, boolean vegetarian, double price) {
        MenuItem menuItem = new MenuItem(name, description, vegetarian, price);
        if (numberOfItems >= MAX_ITEMS) {
            System.out.println("Sorry, menu is full");
        } else {
            menuItems[numberOfItems] = menuItem;
            numberOfItems = numberOfItems + 1;
        }
    }

    /*public MenuItem[] getMenuItems() {
        return menuItems;
    }*/
    public Iterator createIterator() {
        return new DinerMenuIterator(menuItems);
    }

    @Override
    public String toString() {
        return "DinerMenu{" +
                "numberOfItems=" + numberOfItems +
                ", menuItems=" + Arrays.toString(menuItems) +
                '}';
    }
}
